package com.zbl.zblproject.pay.config;

import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConstants;
import com.zbl.zblproject.pay.entity.WXPayClient;
import com.zbl.zblproject.pay.entity.WeixinProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/11/5
 */
@Configuration
@EnableConfigurationProperties(WeixinProperties.class)
public class WXPayConfiguration {

    @Autowired
    private WeixinProperties weixinProperties;

    /**
     * useSandbox true为沙盒环境
     * @return
     */
    @Bean
    public WXPay wxPay() {
        return new WXPay(weixinProperties, WXPayConstants.SignType.MD5, weixinProperties.getUseSandbox() );
    }

    @Bean
    public WXPayClient wxPayClient() {
        return new WXPayClient(weixinProperties, WXPayConstants.SignType.MD5, weixinProperties.getUseSandbox());
    }


}
